import send_email5
import openpyxl

excel_file = openpyxl.load_workbook("names.xlsx")
worksheet = excel_file.active
for index, row in enumerate(worksheet.rows):
    if index > 0:
        # 读取姓名
        name = row[0].value
        # 读取邮箱
        email = row[3].value
        # 确定子文件夹的名字
        subfolder = int(index / 1000) + 1
        # 拼接完整的路径
        file_path = f'letters/{subfolder}/{name}.docx'
        # 调用send_email函数发送邮件
        print(f'正在给{name}发送邀请函...')
        send_email5.send_email(name, email, file_path)
        print(f'发送成功...')
